<template>
	<div>
		 <el-button type="primary" @click="add">添加热点</el-button>
		<el-table :data="tableData" border style="width: 100%">
			<el-table-column fixed prop="memo" label="描述" width="150">
			</el-table-column>
			<el-table-column prop="type" label="类型" width="120">
			</el-table-column>
			<el-table-column prop="hot" label="优先级" width="120">
			</el-table-column>
			<el-table-column label="图片" width="120">
				<template slot-scope="scope">
					<el-image :src="`http://127.0.0.1/api/public/showimg/${scope.row.picture}`"></el-image>
				</template>
			</el-table-column>
			<el-table-column prop="address" label="操作" width="300">
				<template slot-scope="scope">
					<el-button type="primary" size="small" icon="el-icon-edit" @click="goupdate(scope.row)">修改
					</el-button>
				</template>
			</el-table-column>
			<el-table-column prop="zip" label="操作" width="120">
				<template slot-scope="scope">
					<el-button type="text" size="small" @click="del(scope.row.id)">删除</el-button>
				</template>
			</el-table-column>
			<!-- <el-table-column fixed="right" label="操作" width="100">
				<template slot-scope="scope">
					<el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
					<el-button type="text" size="small">编辑</el-button>
				</template>
			</el-table-column> -->
		</el-table>
	</div>

</template>

<script>
	export default {
		methods: {
			add(){
				this.$router.push("/adm/addhotpic")
			},
			handleClick(row) {
				console.log(row);
			},
			getHotGoods() {
				this.$get("/api/adm/hot/findAll").then((resp) => {
					console.log(resp.data.data);
					resp.data.data.forEach((item, i) => {
						this.tableData.push(item)
					})

				})

			},
			del(id) {
				this.$get("/api/adm/hot/remove/" + id).then((resp) => {
					this.getHotGoods();
				})
			},
			goupdate(user) {
				console.log(user);
				this.$router.push({
					path: '/adm/updateHotPic',
					query: {
						type: user.type,
						id: user.id,
						pic: user.picture,
						memo: user.memo,
						hot: user.hot
					}
				})
			},
		},
		mounted() {
			this.getHotGoods();
		},
		data() {
			return {
				tableData: []
			}
		}
	}
</script>

<style>
</style>
